import { InputQuestion, QuestionBase, SelectQuestion } from '@/components/public-template';
import { TextTable } from '@/components/public-template';
import { TableBase } from '@/components/public-template';
import { Api } from '@/config/api/watermark';

class IndexService {
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new InputQuestion({
        key: 'code',
        label: '编码',
        value: null
      }),
      new InputQuestion({
        key: 'name',
        label: '名称',
        value: null
      }),
      new SelectQuestion({
        key: 'isDefault',
        label: '是否默认水印',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'YES_OR_NO'
        }
      })
    ];
    return questions;
  }
  getTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'code',
        value: '编码',
        type: 'slot',
        state: {
          slotName: 'code'
        }
      }),
      new TextTable({
        key: 'name',
        value: '名称'
      }),
      new TextTable({
        key: 'type',
        value: '水印内容',
        type: 'dictionary',
        state: {
          filterName: 'WATERMARK_CONTENT'
        }
      }),
      new TextTable({
        key: 'customizeContent',
        value: '自定义内容'
      }),
      new TextTable({
        key: 'contentType',
        value: '类型',
        type: 'dictionary',
        state: {
          filterName: 'WATERMARK_TYPE'
        }
      }),
      new TextTable({
        key: 'isDefault',
        value: '是否默认水印',
        type: 'dictionary',
        state: {
          filterName: 'YES_OR_NO'
        },
        colors: {
          1: '#ef6262'
        }
      }),
      new TextTable({
        key: 'creatorName',
        value: '创建人'
      }),
      new TextTable({
        key: 'createdTime',
        value: '创建时间',
        columns: {
          width: 200
        }
      }),
      new TextTable({
        key: 'modifierName',
        value: '修改人'
      }),
      new TextTable({
        key: 'modifiedTime',
        value: '修改时间',
        columns: {
          width: 200
        }
      }),
      new TextTable({
        key: 'actions',
        value: '操作',
        columns: {
          width: 150
        },
        handle: [
          {
            type: 'hint',
            text: '设置默认',
            class: 'text-primary',
            url: Api.watermarkSetDefault,
            postType: 'post',
            urlName: 'id',
            params: [{ id: 'id' }],
            state: {
              hintData: {
                title: '是否确定将此水印设置为默认？默认信息只能存在一条。'
              }
            }
          },
          {
            type: 'delete',
            text: '删除',
            class: 'text-primary',
            url: Api.watermarkDelete,
            postType: 'post',
            urlName: 'id',
            state: {}
          }
        ]
      })
    ];
    return tables;
  }
  getIcons() {
    const icons: TableBase<any>[] = [
      new TextTable({
        key: 'local',
        value: '添加',
        type: 'primary',
        class: 'icon-add',
        state: {}
      }),
      new TextTable({
        key: 'delete',
        value: '删除',
        type: 'default',
        class: 'icon-delete',
        state: {
          type: 'array',
          url: Api.watermarkBatchDelete,
          postType: 'post',
          keyName: 'ids'
        }
      })
    ];
    return icons;
  }
}

export default new IndexService();
